package com.woniu.mgr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.mgr.controller.form.LoginForm;
import com.woniu.mgr.model.Manager;
import com.woniu.mgr.dao.ManagerDao;
import com.woniu.mgr.service.ManagerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 管理员表 服务实现类
 * </p>
 *
 * @author Silas
 * @since 2023-02-15
 */
@Service
public class ManagerServiceImpl extends ServiceImpl<ManagerDao, Manager> implements ManagerService {
    @Resource
    private ManagerDao managerDao;

    @Override
    public void login(LoginForm loginForm) {
        Manager manager = managerDao.selectOne(new QueryWrapper<Manager>().eq("username", loginForm.getUsername()));
        if (!manager.getPassword().equals(loginForm.getPassword())) {
            throw new IllegalStateException("密码错误");
        }
    }
}
